/**Login Test**/
package edu.gatech.tests;

import junit.framework.TestCase;
import edu.gatech.applications.Login;
import edu.gatech.userclasses.User;

/**
 * This class tests the login methods
 * @author Tyler Natoli
 * @version 2.0
 */
public class LoginTest extends TestCase {
	/**Login that we are testing**/
	private Login login;
	
	/**
	 * Tests if a registered Patient can log in correctly.
	 * Note: Requires the patient from SetUpUsers
	 * to be in the system.
	 */
	public void testValidateCorrectPatient(){
		login = new Login("Frank", "passwd123");
		User user = login.validate();
		assertEquals("Patient incorrectly found", "Frank", user.getName());
	}
	
	/**
	 * Tests if a registered Nurse can log in correctly.
	 * Note: Requires the patient from SetUpUsers
	 * to be in the system.
	 */
	public void testValidateCorrectNurse(){
		login = new Login("nurse", "candycane");
		User user = login.validate();
		assertEquals("Nurse incorrectly found", "nurse", user.getName());
	}
	
	/**
	 * Tests if a registered Doctor can log in correctly.
	 * Note: Requires the patient from SetUpUsers
	 * to be in the system.
	 */
	public void testValidateCorrectDoctor(){
		login = new Login("Doctor", "lara");
		User user = login.validate();
		assertEquals("Doctor incorrectly found", "Doctor", user.getName());
	}
	
	/**
	 * Tests if a registered Doctor can log in correctly.
	 * Note: Requires the patient from SetUpUsers
	 * to be in the system.
	 */
	public void testValidateCorrectSysAdmin(){
		login = new Login("Admin", "penguin");
		User user = login.validate();
		assertEquals("System Admin incorrectly found", "Admin", user.getName());
	}
	
	/**
	 * Tests if an invalid username but valid password is given
	 */
	public void testInvalidUsername(){
		login = new Login("UGA", "passwd123");
		User user = login.validate();
		assertNull("Login should not find a user", user);
	}
	
	/**
	 * Tests if a valid username but invalid password is given
	 */
	public void testInvalidPassword(){
		login = new Login("Frank", "UGA");
		User user = login.validate();
		assertNull("Login should not find a user", user);
	}
	
	/**
	 * Makes sure if a user accidently presses enter
	 * no null pointer exceptions occur.
	 */
	public void testEmptyPassword(){
		login = new Login("Frank", "");
		User user = login.validate();
		assertNull("Login should not find a user", user);
	}
}
